package cn.sunlight.college.eduTest.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.metadata.CellData;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @ClassName ExcelListener
 * @Description 读取excel操作的监听器
 * @Author liugang
 * @Date 2021/6/14 ~ 1:36 下午
 * @Version V1.0
 */
public class ExcelListener extends AnalysisEventListener<DemoData> {

    //创建list集合封装最终的数据
    List<DemoData> list=new ArrayList<>();

    /**
     * 一行一行去读取excle内容
     * @param data
     * @param analysisContext
     */
    @Override
    public void invoke(DemoData data, AnalysisContext analysisContext) {
        System.out.println("***"+data);
        list.add(data);
    }

    /**
     * 读取excel表头信息
     * @param headMap
     * @param context
     */
    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        System.out.println("表头信息："+headMap);
    }

    /**
     * 读取完成后执行
     * @param analysisContext
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
